import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

import axios from '@/plugins/axios.js'

import VueLazyload from 'vue-lazyload'
Vue.use(axios, {
  baseUrl: 'http://rap2.taobao.org:38080/app/mock/247256'
})

// Vue.use(VueLazyload)
//设置默认的option
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: require("@/assets/images/error.jpg"),
  loading: require("@/assets/images/loading.gif"),
  attempt: 2 //加载错误后最大尝试次数
})

router.beforeEach((to, from, next) => {
  if (to.name == 'Home') {
    //调用mutations
    store.commit('updateUserInfo', { userName: "homeLixin", userId: '12345678' });
    store.commit('login/updateAccessToken', "111111111111111");

    //调用actions
    store.dispatch('login/updateToken', "22222");
  }
  next()
})

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
